package com.pcbly.web.business.jbpm;

import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.history.HistoryActivityInstance;
import org.jbpm.api.identity.Group;
import org.jbpm.api.identity.User;
import org.jbpm.api.job.Job;
import org.jbpm.api.model.ActivityCoordinates;
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.model.Transition;

public interface JbpmService {
	List<ProcessDefinition> getLatestProcessDefinitions() throws Exception;

	List<ProcessDefinition> getSuspendedProcessDefinitions() throws Exception;

	void deployXml(String name, InputStream inputStream) throws Exception;
	void deployXml(String name, StringBuffer sb) throws Exception;

	void deployZip(InputStream inputStream) throws Exception;

	void deployXml(String xml) throws Exception;

	void suspendProcessDefinitionById(String id) throws Exception;

	void resumeProcessDefinitionById(String id) throws Exception;

	void removeProcessDefinitionById(String id) throws Exception;

	Set<String> getTransitionsForTask(String id) throws Exception;

	List<Transition> getTransitionsForSignalProcess(String id) throws Exception;

	void completeTask(String dbid, String transitionName,
			Map<String, Object> variables) throws Exception;

	void startProcess(String id, Map<String, Object> variables)
			throws Exception;

	void signalProcess(String id, String transitionName,
			Map<String, Object> variables) throws Exception;

	List<ProcessInstance> getProcessInstances(String pdId) throws Exception;

	List<ProcessInstance> getSuspendedProcessInstances() throws Exception;

	ActivityCoordinates getActivityCoordinates(String id) throws Exception;

	void suspendProcessInstance(String id) throws Exception;

	void resumeProcessInstance(String id) throws Exception;

	void endProcessInstance(String id) throws Exception;

	void removeProcessInstance(String id) throws Exception;

	Map<String, Object> getVariablesForTask(String id) throws Exception;

	Map<String, Object> getVariablesForProcess(String id) throws Exception;

	List<Task> getTasks() throws Exception;

	List<Task> getPersonalTasks(String username) throws Exception;

	List<Task> getGroupTasks(String username) throws Exception;

	void takeTask(String dbid, String username) throws Exception;

	void cancelTask(String dbid) throws Exception;

	void releaseTask(String dbid) throws Exception;

	InputStream getResourceFromProcessDefinition(String processDefinitionId) throws Exception;

	InputStream getResourceFromProcessInstance(String processInstanceId) throws Exception;

	List<User> getUsers() throws Exception;

	List<Group> getGroupsByUser(String id) throws Exception;

	void addUser(String id, String password, String givenName, String familyName)
			throws Exception;

	void removeUser(String id) throws Exception;

	List<Group> getGroups() throws Exception;

	void addGroup(String name, String type, String parentGroupId)
			throws Exception;

	void removeGroup(String id) throws Exception;

	void addMember(String userId, String groupId, String role) throws Exception;

	boolean checkLogin(String username, String password) throws Exception;

	ProcessDefinition getProcessDefinitionByProcessInstanceId(
			String processInstanceId) throws Exception;

	String reportOverallActivity() throws Exception;

	String reportMostActiveProcess() throws Exception;

	List<ActivityCoordinates> getHistoryActivities(String processInstanceId)
			throws Exception;

	List<HistoryActivityInstance> getHistoryActivitiesByProcessInstanceId(
			String processInstanceId) throws Exception;

	List<Job> getJobs() throws Exception;

}
